function result = summary_stats_SV(rets_cell , rets_string , latex_out , log_or_simple , file_name)

% This function creates a table of summary statistics computations for signed trading volume

T = size(rets_cell{:,1},1);
N = size(rets_cell,2);

if log_or_simple == 1
    
    LHV = [];
    RHV = [];
    for k = 1 : N
        LHV             = [LHV ; rets_cell{:,k}];
        temp            = zeros(length(rets_cell{:,k}),N);
        temp(:,k)       = 1;
        RHV             = [RHV ; temp];
    end
    
    results             = olsgmm(LHV,RHV,1,1);
    tstatsX(1,:)        = results.tstat;
    
    obs = []; meanX = []; medianX = []; stdX = []; minX = []; maxX = []; skewX = []; kurtX = []; autocorrX = [];
        
    for k = 1 : N
        obs(1,k)            = length(rets_cell{:,k});
        meanX(1,k)          = nanmean(rets_cell{:,k});
        medianX(1,k)        = nanmedian(rets_cell{:,k});
        stdX(1,k)           = nanstd(rets_cell{:,k});
        minX(1,k)           = min(rets_cell{:,k});
        maxX(1,k)           = max(rets_cell{:,k});
        skewX(1,k)          = skewness(rets_cell{:,k});
        kurtX(1,k)          = kurtosis(rets_cell{:,k});
    end
            
    for k = 1 : N
        temp                = autocorr(rets_cell{:,k},1);
        autocorrX(1,k)      = temp(2);
    end
    
    % Now do binomial test
    pout = []; pos = [];  neg = [];
    p = 1/2;
    for k = 1 : N
        s                   = sign(rets_cell{:,k});
        pos(1,k)            = sum(s(:)==1);
        neg(1,k)            = sum(s(:)==-1);
        zer(1,k)            = sum(s(:)==0);
        pout(1,k)           = myBinomTest(pos(1,k),[pos(1,k)+neg(1,k)],p,'two');
    end
    
    out = [meanX;
        tstatsX;
        medianX;
        stdX;
        skewX;
        kurtX];
    
    info.cnames = strvcat(rets_string);
    info.rnames = strvcat('Hour' , 'Mean' , 't-stat' , 'Median' , 'Sdev' , 'Skew' , 'Kurt');
    info.fmt = '%6.2f';
    info.swidth = 220;
    info.hspc = 5;
    mprint1(out, info);
    if latex_out == 1
        info.fid = file_name;
        latextab2a(out, info)
    end
    
    
elseif log_or_simple == 2 % BROKEN FROM HERE DOWN NEED TO UPDATE FROM ABOVE
    
    LHV = [];
    RHV = [];
    for k = 1 : N
        LHV                 = [LHV ; rets_cell{:,k}];
        temp                = zeros(T,N);
        temp(:,k)           = 1;
        RHV                 = [RHV ; temp];
    end
    
    results                 = olsgmm(LHV,RHV,1,1);
    tstatsX(1,:)            = results.tstat;
    
    
    for k = 1 : N
        obs(1,k)            = length(rets_cell{:,k});
        meanX(1,k)          = ((nangeomean(1+rets_cell{:,k},1))-1);
        medianX(1,k)        = nanmedian(rets_cell{:,k});
        stdX(1,k)           = nanstd(log(1+rets_cell{:,k}));
        minX(1,k)           = min(rets_cell{:,k});
        maxX(1,k)           = max(rets_cell{:,k});
        skewX(1,k)          = skewness(rets_cell{:,k});
        kurtX(1,k)          = kurtosis(rets_cell{:,k});
    end
    
    for k = 1 : N
        temp                = autocorr(rets_cell{:,k},1);
        autocorrX(1,k)      = temp(2);
    end
    
    % Now do binomial test
    pout = []; pos = [];  neg = [];
    p = 1/2;
    for k = 1 : N
        s                   = sign(rets_cell{:,k});
        pos(1,k)            = sum(s(:)==1);
        neg(1,k)            = sum(s(:)==-1);
        zer(1,k)            = sum(s(:)==0);
        pout(1,k)           = myBinomTest(pos(1,k),[pos(1,k)+neg(1,k)],p,'two');
    end
    
    out = [meanX;
        tstatsX;
        medianX;
        stdX;
        skewX;
        kurtX];
    
    info.cnames = strvcat(rets_string);
    info.rnames = strvcat('Hour' , 'Mean' , 't-stat' , 'Median' , 'Sdev' , 'Skew' , 'Kurt');
    info.fmt = '%6.2f';
    info.swidth = 220;
    info.hspc = 5;
    mprint1(out, info);
    if latex_out == 1
        info.fid = file_name;
        latextab2a(out, info)
    end
    
    
end
result = [];